// Copyright  2004-2008 Backplane Ltd.
//
// This file is part of Ubiquity formsPlayer
//
// Ubiquity formsPlayer is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
//
// Ubiquity formsPlayer is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License
// along with Ubiquity formsPlayer If not, see <http://www.gnu.org/licenses/>.
//	
//
//   Purpose:  Definition of CTempDocImpl..
//   $Id$

#pragma once

#include <Common/ImplReg/msw/ImplRegUtils.h>
#include <Common/COM/msw/IDispatchLite.h>

class CTempDocImpl
{
public:
	// Construction.
	CTempDocImpl();

	// Destruction.
	~CTempDocImpl();

	// This method returns the implementation.
	HRESULT GetImplementation(IDOMImplementation **ppImpl);

private:
	// Private initialisation method.
	HRESULT Init(void);

	// The implementation registry.
	CComPtr<IDOMImplementationRegistry> m_pImplReg;

	// The implementation.
	CComPtr<IDOMImplementation> m_pImplementation;

	// Forbidden operations.
	CTempDocImpl(const CTempDocImpl &rhs);
	CTempDocImpl &operator=(const CTempDocImpl &rhs);
};

// Implements document.hasFeature()
class CDocumentImplementationHasFeature
	: public CIDispatchLite
	//, public IObjectSafetyImpl<CDocumentImplementationHasFeature, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA>
{
public:
	STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *pvResult, EXCEPINFO *pexcepinfo, UINT *puArgErr);

	static HRESULT CreateInstance(CDocumentImplementationHasFeature **ppHasFeature);

	HRESULT Initialise(IDOMImplementation *pImpl);

protected:
	CDocumentImplementationHasFeature();
	virtual ~CDocumentImplementationHasFeature();

private:
	// Explicitly forbidden operations.
	CDocumentImplementationHasFeature(const CDocumentImplementationHasFeature &rhs);
	CDocumentImplementationHasFeature &operator=(const CDocumentImplementationHasFeature &rhs);

	CComPtr<IDOMImplementation> m_pImpl;
};

// Implements document.getFeature()
class CDocumentImplementationGetFeature
	: public CIDispatchLite
	//, public IObjectSafetyImpl<CDocumentImplementationGetFeature, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA>
{
public:
	STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *pvResult, EXCEPINFO *pexcepinfo, UINT *puArgErr);

	static HRESULT CreateInstance(CDocumentImplementationGetFeature **ppGetFeature);

	HRESULT Initialise(IDOMImplementation *pImpl);

protected:
	CDocumentImplementationGetFeature();
	virtual ~CDocumentImplementationGetFeature();

private:
	// Explicitly forbidden operations.
	CDocumentImplementationGetFeature(const CDocumentImplementationGetFeature &rhs);
	CDocumentImplementationGetFeature &operator=(const CDocumentImplementationGetFeature &rhs);

	CComPtr<IDOMImplementation> m_pImpl;
};

// Implements document.createEvent()
class CDocumentEventCreateEvent
	: public CIDispatchLite
	//, public IObjectSafetyImpl<CDocumentEventCreateEvent, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA>
{
public:
	
#ifdef _DEBUG
	virtual unsigned long STDMETHODCALLTYPE Release(void)
	{
		unsigned long l = __super::Release();
		return l;
	}

	virtual unsigned long STDMETHODCALLTYPE AddRef(void)
	{
		unsigned long l = __super::AddRef();
		return l;
	}
#endif
	STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *pvResult, EXCEPINFO *pexcepinfo, UINT *puArgErr);

	static HRESULT CreateInstance(CDocumentEventCreateEvent **ppCreateEvent);

	HRESULT Initialise(void);

protected:
	CDocumentEventCreateEvent();
	virtual ~CDocumentEventCreateEvent();

private:
	// Explicitly forbidden operations.
	CDocumentEventCreateEvent(const CDocumentEventCreateEvent &rhs);
	CDocumentEventCreateEvent &operator=(const CDocumentEventCreateEvent &rhs);

	CComPtr<IDocumentEvent> m_pDocEvent;
};

